$(document).ready(function(){
    var VAL ={
        NORMAL       : "0000000"  ,
        EVT_USER     : $("#userId").text(),
        T_FIPINQSHT  : "FIPINQSHT",
        T_FBPBISOPE : "FBPBISOPE"
    };
    var domObj={
        $prdListDiv : $("#prdListDiv"),
        $prdInfoGrd : $("#prdInfoGrd"),
        prdInfoPg   : $("#prdInfoPg"),
        $prd_info_id	 : $("#prd_info_id"),

        //表格信息
        $prd_seq_id : $("#prd_seq_id"),
        $slot_no    : $("#slot_no"),
        $mdl_id_fk    : $("#mdl_id_fk"),
        $prd_stat    : $("#prd_stat"),
        $prd_qty    : $("#prd_qty"),
        $prd_grade    : $("#prd_grade"),
        $prd_thickness   : $("#prd_thickness"),
        $tool_id_fk   : $("#tool_id_fk"),
        $wo_id_fk   : $("#wo_id_fk"),
        $ac_recipe_id   : $("#ac_recipe_id"),
        $pallet_id   : $("#pallet_id"),

        $crPathIdFk   : $("#crPathIdFk"),
        $crPathVerFk   : $("#crPathVerFk"),
        $crOpeNoFk   : $("#crOpeNoFk"),
        $crOpeIdFk   : $("#crOpeIdFk"),
        $crOpeVerFk   : $("#crOpeVerFk"),
        $crOpeDscFk : $("#crOpeDscFk"),
        $crProcIdFk   : $("#crProcIdFk"),
        $crToolgIdFk  : $("#crToolgIdFk"),
        $crToolRunMode  : $("#crToolRunMode"),
        $crToolIdFk   : $("#crToolIdFk"),
        $box_id_fk : $("#box_id_fk"),
        $ship_box_id_fk : $("#ship_box_id_fk"),
        $Appearance:      $("#Appearance"),
        $Telecommunications: $("#Telecommunications"),
        $DefectCode: $("#DefectCode"),
        buttons:{
            $query_btn: $("#query_btn")
        }

    };
    var btnFunc={
        query_func: function(){
        	$("span").html("");
            var prd_info_id = domObj.$prd_info_id.val();
            if (!prd_info_id) {
                showErrorDialog("","请输入屏体代码！");
                return;
            }
            var inObj ={
                trx_id : VAL.T_FIPINQSHT,
                action_flg: 'Q',
                prd_seq_id  : prd_info_id
            };
            var outObj = comTrxSubSendPostJson(inObj);
            if (outObj.rtn_code === VAL.NORMAL) {
                domObj.$prd_seq_id.html(outObj.prd_seq_id);
                domObj.$box_id_fk.html(outObj.box_id_fk);
                domObj.$ship_box_id_fk.html(outObj.ship_box_id_fk);
                domObj.$slot_no.html(outObj.slot_no);
                domObj.$mdl_id_fk.html(outObj.mdl_id_fk);
                domObj.$prd_stat.html(outObj.prd_stat);
                domObj.$prd_qty.html(outObj.prd_qty);
                domObj.$prd_grade.html(outObj.prd_grade);
                domObj.$prd_thickness.html(outObj.prd_thickness);
                domObj.$tool_id_fk.html(outObj.tool_id_fk);
                domObj.$wo_id_fk.html(outObj.wo_id_fk);
                domObj.$ac_recipe_id.html(outObj.ac_recipe_id);
                domObj.$pallet_id.html(outObj.pallet_id);
                domObj.$Appearance.html(outObj.ext_6);
                domObj.$Telecommunications.html(outObj.ext_4);

                domObj.$crPathIdFk.html(outObj.path_id_fk);
                domObj.$crPathVerFk.html(outObj.path_ver_fk);
                domObj.$crOpeNoFk.html(outObj.ope_no_fk);
                domObj.$crOpeIdFk.html(outObj.ope_id_fk);
                domObj.$crOpeVerFk.html(outObj.ope_ver_fk);
                domObj.$DefectCode.html(outObj.rsn_code);
                //站点描述  能不能给玻璃加个栏位。。
                if(outObj.prd_stat!='COMP'){
                    var iary2 = {
                        ope_id :   outObj.ope_id_fk,
                        ope_ver :  outObj.ope_ver_fk
                    };
                    var inObj2 ={
                        trx_id : VAL.T_FBPBISOPE,
                        action_flg: 'Q',
                        iary : [iary2]
                    };
                    var outObj2 = comTrxSubSendPostJson(inObj2);
                    if(outObj2.rtn_code === VAL.NORMAL){
                        if(outObj2.oary[0] != null){
                            domObj.$crOpeDscFk.html(outObj2.oary[0].ope_dsc);
                        }
                    }
                }
                domObj.$crProcIdFk.html(outObj.proc_id_fk);
                domObj.$crToolgIdFk.html(outObj.toolg_id_fk);
                domObj.$crToolRunMode.html(outObj.tool_run_mode);
                domObj.$crToolIdFk.html(outObj.tool_id_fk);
            }
        }
    };
    
	var clearInfo= function(){
		$("input").val("");
	};
	
    var otherActionBind = function(){
        //Stop from auto commit
        $("form").submit(function(){
            return false;
        });

    };
    domObj.$prd_info_id.keydown(function(event) {
        if (event.which == 13) {
            btnFunc.query_func();
        }
    });
    var iniButtonAction=function(){
        domObj.buttons.$query_btn.click(function(){
            btnFunc.query_func();
        });
    };

    var initializationFunc = function(){
    	clearInfo();
        otherActionBind();
        iniButtonAction();
    };

    initializationFunc();
    //enter
    /*document.onkeydown=function(event){
        var e = event || window.event || arguments.callee.caller.arguments[0];
        if(e && e.keyCode==13){ // 按 enter
            $('.bootbox').modal("hide");
        }
    }*/
});